﻿using System;
using System.Configuration;
using NUnit.Framework;
using WaveTech.GShield.Common;
using WaveTech.GShield.Model;
using WaveTech.GShield.Repositories.Azure;

namespace WaveTech.GShield.UnitTests.Data
{
	[TestFixture]
	public class AzureGameRatingRepositoryTests
	{
		[Test]
		public void TestGameRating()
		{
			GameRating initialRating = new GameRating();
			initialRating.FileName = "Test2";
			initialRating.Directory = "D:\\Games\\MyGame2";
			initialRating.GameRatingId = Guid.NewGuid();
			initialRating.ProductName = "Test2";
			initialRating.Publisher = "My company";
			initialRating.Rating = RatingTypes.Mature;
			initialRating.Title = "My Game2";

			GameRatingRepository repo = new GameRatingRepository(ConnectionStrings.GetSsdsConnectionString());
			repo.InsertGameRating(initialRating);

			GameRating r = repo.GetGameRating(initialRating.GameRatingId);

			Assert.IsNotNull(r);
			Assert.AreEqual(r.Title, initialRating.Title);
			Assert.AreEqual(r.FileName, initialRating.FileName);
			Assert.AreEqual(r.Directory, initialRating.Directory);
			Assert.AreEqual(r.ProductName, initialRating.ProductName);
			Assert.AreEqual(r.Publisher, initialRating.Publisher);
			Assert.AreEqual(r.Rating, initialRating.Rating);

			repo.DeleteGameRating(initialRating.GameRatingId);
			GameRating r2 = repo.GetGameRating(initialRating.GameRatingId);
			Assert.IsNull(r2);
		}
	}
}